home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11251 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: locutus.rchland.ibm.com!usenet
  2. From: Philip Staite <pstaite+@rchland.ibm.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Virtual Base Class
  5. Date: Wed, 13 Mar 1996 07:48:38 -0600
  6. Organization: IBM Rochester, MN
  7. Message-ID: <3146D236.41C6@rchland.ibm.com>
  8. References: <313F98D0.102E@ucla.edu> <4i1k92$3n8@apoll.informatik.uni-bonn.de>
  9. NNTP-Posting-Host: powertool.rchland.ibm.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (X11; I; AIX 1)
  14.  
  15. Roland Schregle wrote:
  16. > Dennis Rahaman (dennisr@ucla.edu) wrote:
  17. > : This is what I want to do:
  18. > :               a
  19. > :             /   \
  20. > :            b     c
  21. > :             \   /
  22. > :               d
  23.  
  24. <edited>
  25.  
  26. > I have the same problem! Somebody suggested the following (in terms of the
  27. > above egg sample):
  28. > void f()
  29. > {
  30. >    a a1;
  31. >    d* pd = (d*)(void*)&a1;
  32. > }
  33. > I haven't tried this yet. C'mon you C++ cracks out there!!! :)
  34.  
  35. No no no NO!
  36.  
  37. An 'a' is _NOT_ a 'd' -- therefore casting the address of an a object to
  38. be a pointer to a d object is just plain wrong, probably immoral, and
  39. maybe even fattening.
  40.  
  41. Think for a minute, you really don't have a d object there, just an a
  42. object.  It would be different if it really was a d object that was
  43. given to this code via an a*...  Then the cast would make more sense.
  44.  
  45. -- 
  46.  
  47. Phil Staite, (507) 253-2529, team OS/2
  48. internet: pstaite@vnet.ibm.com  internal: pstaite@rchland
  49.